-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(explore): Dashboard list is unsorted in save modal #21317
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21317 +/- ##
==========================================
+ Coverage 66.82% 66.84% +0.01%
==========================================
Files 1798 1798
Lines 68827 68829 +2
Branches 7333 7333
==========================================
+ Hits 45997 46012 +15
+ Misses 20951 20932 -19
- Partials 1879 1885 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
/testenv up |
@geido Ephemeral environment spinning up at http://35.86.118.87:8080. Credentials are |
@michael-s-molina I'd like your opinion here. I don't think this problem is related to this PR but testing with numeric dashboards I am getting an unwanted behaviour. I believe this could be the same problem that was reported elsewhere. Probably worth having a sync session about it. |
if (labelA < labelB) { | ||
return -1; | ||
} | ||
if (labelA > labelB) { | ||
return 1; | ||
} | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (labelA < labelB) { | |
return -1; | |
} | |
if (labelA > labelB) { | |
return 1; | |
} | |
return 0; | |
return labelA.localeCompare(labelB); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-s-molina @geido Made a change so that when a string begins with a number it sorts numerically instead. Does not fix all the cases but addresses several.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agl-developer What you're trying to achieve is a concept called Natural Sorting. This is already supported natively by localeCompare using { sensitivity: 'base', numeric: true }
@agl-developer Would you mind updating |
choices.sort((a, b) => { | ||
const labelA = a.label.toUpperCase(); | ||
const labelB = b.label.toUpperCase(); | ||
return labelA.localeCompare(labelB, { | ||
sensitivity: 'base', | ||
numeric: true, | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sensitivity: 'base' already handles case sensitivity.
choices.sort((a, b) => { | |
const labelA = a.label.toUpperCase(); | |
const labelB = b.label.toUpperCase(); | |
return labelA.localeCompare(labelB, { | |
sensitivity: 'base', | |
numeric: true, | |
}); | |
}); | |
choices.sort((a, b) => | |
a.label.localeCompare(b.label, { | |
sensitivity: 'base', | |
numeric: true, | |
}), | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ephemeral environment shutdown and build artifacts deleted. |
SUMMARY
Listed dashboards in the save chart modal should show up alphabetically.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
After:
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION